package org.fastsyncer.biz.impl;

import org.fastsyncer.biz.MappingService;
import org.fastsyncer.manager.Manager;
import org.fastsyncer.parser.Mapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author AE86
 * @version 2.0.0
 * @date 2019/10/17 23:20
 */
@Service
public class MappingServiceImpl implements MappingService {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private Manager manager;

    @Override
    public String save(String json) {
        logger.info("检查驱动是否停止运行");
        return manager.saveMapping(json);
    }

    @Override
    public boolean remove(String mappingId) {
        manager.removeMapping(mappingId);
        return true;
    }

    @Override
    public List<Mapping> getMappingAll() {
        return manager.getMappingAll();
    }

    @Override
    public boolean start(String mappingId) {
        manager.start(mappingId);
        return true;
    }

    @Override
    public boolean stop(String mappingId) {
        manager.stop(mappingId);
        return true;
    }
}
